﻿//********************************************************************************//
//创建日期：<创建日期，2016-03-14>
//创建作者：<郭登杰，guodengjie@shanghai3h.com>
//功能说明：发票库存Model
//********************************************************************************//
using System;
using System.Collections.Generic;
using YXYLCommon;
using System.Data;

namespace Entity
{
    [Serializable]
    /// <summary>
    /// 用户信息
    /// </summary>
    public class XTUSER : BaseModel
    {
        public XTUSER()
        {
          
        }
        public int USERID { get; set; }

        public string USERNAME { get; set; }

        public string ACCOUNT { get; set; }

        public string PASSWORD { get; set; }

        public int ISACTIVE { get; set; }

        public int DEPARTMENT { get; set; }

        public string DEPARTMENTNAME { get; set; }

        public string TELEPHONE { get; set; }

        public string MOBILEPHONE { get; set; }

        public string EMAIL { get; set; }

        public string IDCARD { get; set; }

        public string BIRTHDAY { get; set; }

        public int GENDER { get; set; }

        public string ADDRESS { get; set; }

        public string POSTCODE { get; set; }


        public string USERDESC { get; set; }

        public string SFSC { get; set; }

        public override BaseModel ToObject(System.Data.DataRow row)
        {
            this.IsExists = true;
            this.ACCOUNT = Convert.ToString(row["ACCOUNT"]);
            this.ADDRESS = Convert.ToString(row["ADDRESS"]);
            this.BIRTHDAY = Convert.ToString(row["BIRTHDAY"]);
            this.DEPARTMENT = Convert.ToInt32(row["DEPARTMENT"]);
            this.DEPARTMENTNAME = Convert.ToString(row["DEPARTMENTNAME"]);
            this.USERDESC = Convert.ToString(row["USERDESC"]);
            this.EMAIL = Convert.ToString(row["EMAIL"]);
            this.GENDER = Convert.ToInt32(row["GENDER"]);
            this.IDCARD = Convert.ToString(row["IDCARD"]);
            this.ISACTIVE = Convert.ToInt32(row["ISACTIVE"]);
            this.MOBILEPHONE = Convert.ToString(row["MOBILEPHONE"]);
            this.PASSWORD = Convert.ToString(row["PASSWORD"]);
            this.POSTCODE = Convert.ToString(row["POSTCODE"]);
            this.TELEPHONE = Convert.ToString(row["TELEPHONE"]);
            this.USERID = Convert.ToInt32(row["USERID"]);
            this.USERNAME = Convert.ToString(row["USERNAME"]);
            this.SFSC = row.Table.Columns.Contains("SFSC") ? Convert.ToString(row["SFSC"]) : null;
            return this;
        }
    }
    public class DALXTUSER : BaseDAL
    {
        public DALXTUSER()
        {

        }
        protected override void fillSaveProc(BaseModel model)
        {
            //YS_ZW_FAPIAOKC obj = (YS_ZW_FAPIAOKC)model;
        }


        public DbCmdResult Save(XTUSER obj)
        {
            dbProc.Init("P_XT_USERSAVE");
            dbProc.AddParameter("V_ACCOUNT", obj.ACCOUNT);
            dbProc.AddParameter("V_ADDRESS", obj.ADDRESS);
            dbProc.AddParameter("V_BIRTHDAY", obj.BIRTHDAY);
            dbProc.AddParameter("V_DEPARTMENT", obj.DEPARTMENT);
            dbProc.AddParameter("V_USERDESC", obj.USERDESC);
            dbProc.AddParameter("V_EMAIL", obj.EMAIL);
            dbProc.AddParameter("V_GENDER", obj.GENDER);
            dbProc.AddParameter("V_IDCARD", obj.IDCARD);
            dbProc.AddParameter("V_ISACTIVE", obj.ISACTIVE);
            dbProc.AddParameter("V_MOBILEPHONE", obj.MOBILEPHONE);
            //dbProc.AddParameter("V_PASSWORD", obj.PASSWORD);
            dbProc.AddParameter("V_POSTCODE", obj.POSTCODE);
            dbProc.AddParameter("V_TELEPHONE", obj.TELEPHONE);
            dbProc.AddParameter("V_USERID", obj.USERID);
            dbProc.AddParameter("V_USERNAME", obj.USERNAME);
            dbProc.AddParameter("V_OPERATE", obj.Operate.ToString().ToUpper());
            return CommonService.Ini().ExcuteProcOracle(dbProc);
        }

        public List<XTUSER> Get(string name,int bm,int active)
        {
            dbProc.Init("P_XT_USERLIST");
            dbProc.AddParameter("V_NAME", name);
            dbProc.AddParameter("V_BM", bm);
            dbProc.AddParameter("V_ACTIVE", active);
            return CommonService.Ini().GetList<XTUSER>(dbProc);
        }

        public XTUSER GetInfo(int id)
        {
            dbProc.Init("P_XT_USERINFO");
            dbProc.AddParameter("V_USERID", id);
            return CommonService.Ini().GetObject<XTUSER>(dbProc);
        }
    }

}